package business

import (
	"shop-service/repository"
	"shop-service/service"
)

var impl *serviceImpl

func RegisterService() {
	// 附件
	attachRepository := repository.NewAttachFileRepository()
	attachService := service.NewAttachFileService(attachRepository)

	referenceRepository := repository.NewProdTagReferenceRepository()

	impl = &serviceImpl{
		AttachFileService:        attachService,
		CategoryService:          service.NewCategoryService(attachService, repository.NewCategoryRepository()),
		ProdTagService:           service.NewProdTagService(repository.NewProdTagRepository()),
		AreaService:              service.NewAreaService(repository.NewAreaRepository()),
		PickAddrService:          service.NewPickAddrService(repository.NewPickAddrRepository()),
		NoticeService:            service.NewNoticeService(attachService, repository.NewNoticeRepository()),
		UserService:              service.NewUserService(repository.NewUserRepository()),
		TransportService:         service.NewTransportService(repository.NewTransportRepository(), repository.NewTransfeeRepository(), repository.NewTransfeeFreeRepository()),
		ProductService:           service.NewProductService(attachService, referenceRepository, repository.NewProductRepository()),
		IndexImgService:          service.NewIndexImgService(attachService, repository.NewIndexImgRepository()),
		UserAddrService:          service.NewUserAddrService(repository.NewUserAddrRepository()),
		OrderService:             service.NewOrderService(),
		BasketService:            service.NewBasketService(),
		ProdTagReferenceService:  service.NewProdTagReferenceService(referenceRepository),
		StoreCategoryService:     service.NewStoreCategoryService(),
		ShippingTemplatesService: service.NewShippingTemplatesService(),
		PictureService:           service.NewPictureService(),
		FileService:              service.NewFileService(),
		StoreProduct:             service.NewStoreProductService(),
		SystemStore:              service.NewSystemStoreService(),
	}
}

type serviceImpl struct {
	AttachFileService        service.IAttachFileService
	CategoryService          service.ICategoryService
	ProdTagService           service.IProdTagService
	AreaService              service.IAreaService
	PickAddrService          service.IPickAddrService
	NoticeService            service.INoticeService
	UserService              service.IUserService
	TransportService         service.ITransportService
	ProductService           service.IProductService
	IndexImgService          service.IIndexImgService
	UserAddrService          service.IUserAddrService
	OrderService             service.IOrderService
	BasketService            service.IBasketService
	ProdTagReferenceService  service.IProdTagReferenceService
	PictureService           service.IPictureService
	FileService              service.IFileService
	StoreCategoryService     service.IStoreCategoryService
	ShippingTemplatesService service.IShippingTemplatesService
	StoreProduct             service.IStoreProductService
	SystemStore              service.ISystemStoreService
}

func ServiceImpl() *serviceImpl {
	return impl
}
